package com.training.web.controller.comtent;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.training.common.annotation.Log;
import com.training.common.core.controller.BaseController;
import com.training.common.core.domain.AjaxResult;
import com.training.common.enums.BusinessType;
import com.training.content.domain.IndustryType;
import com.training.content.service.IIndustryTypeService;
import com.training.common.utils.poi.ExcelUtil;
import com.training.common.core.page.TableDataInfo;

/**
 * 行业信息Controller
 * 
 * @author training
 * @date 2021-10-25
 */
@RestController
@RequestMapping("/industry")
public class IndustryTypeController extends BaseController
{
    @Autowired
    private IIndustryTypeService industryTypeService;

    /**
     * 查询行业信息列表
     */
    @PreAuthorize("@ss.hasPermi('industry:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(IndustryType industryType)
    {
        startPage();
        List<IndustryType> list = industryTypeService.selectIndustryTypeList(industryType);
        return getDataTable(list);
    }

    /**
     * 导出行业信息列表
     */
    @PreAuthorize("@ss.hasPermi('industry:type:export')")
    @Log(title = "行业信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(IndustryType industryType)
    {
        List<IndustryType> list = industryTypeService.selectIndustryTypeList(industryType);
        ExcelUtil<IndustryType> util = new ExcelUtil<IndustryType>(IndustryType.class);
        return util.exportExcel(list, "行业信息数据");
    }

    /**
     * 获取行业信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('industry:type:query')")
    @GetMapping(value = "/{industryId}")
    public AjaxResult getInfo(@PathVariable("industryId") Long industryId)
    {
        return AjaxResult.success(industryTypeService.selectIndustryTypeByIndustryId(industryId));
    }

    /**
     * 新增行业信息
     */
    @PreAuthorize("@ss.hasPermi('industry:type:add')")
    @Log(title = "行业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IndustryType industryType)
    {
        return toAjax(industryTypeService.insertIndustryType(industryType));
    }

    /**
     * 修改行业信息
     */
    @PreAuthorize("@ss.hasPermi('industry:type:edit')")
    @Log(title = "行业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IndustryType industryType)
    {
        return toAjax(industryTypeService.updateIndustryType(industryType));
    }

    /**
     * 删除行业信息
     */
    @PreAuthorize("@ss.hasPermi('industry:type:remove')")
    @Log(title = "行业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{industryIds}")
    public AjaxResult remove(@PathVariable Long[] industryIds)
    {
        return toAjax(industryTypeService.deleteIndustryTypeByIndustryIds(industryIds));
    }
}
